package com.gec.zhs.controller;

import java.util.List;

import com.gec.zhs.entity.query.ResourceQuery;
import com.gec.zhs.entity.po.Resource;
import com.gec.zhs.entity.vo.ResponseVO;
import com.gec.zhs.service.ResourceService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 资源表 Controller
 */
@RestController("resourceController")
@RequestMapping("/resource")
public class ResourceController extends ABaseController{

	@Resource
	private ResourceService resourceService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(ResourceQuery query){
		return getSuccessResponseVO(resourceService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(Resource bean) {
		resourceService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Resource> listBean) {
		resourceService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Resource> listBean) {
		resourceService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getResourceById")
	public ResponseVO getResourceById(String id) {
		return getSuccessResponseVO(resourceService.getResourceById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateResourceById")
	public ResponseVO updateResourceById(Resource bean,String id) {
		resourceService.updateResourceById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteResourceById")
	public ResponseVO deleteResourceById(String id) {
		resourceService.deleteResourceById(id);
		return getSuccessResponseVO(null);
	}
}